package com.bdqn.action;

import com.bdqn.entity.OuProjectOrder;
import com.bdqn.mapper.OuProjectOrderMapper;
import com.bdqn.service.TestService;
import com.opensymphony.xwork2.ActionSupport;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * Created by Administrator on 2015/8/28.
 */
public class TestAction extends ActionSupport{

    @Resource
    OuProjectOrderMapper projectOrderMapper;

    @Resource
    TestService testService;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    String id;

    public String getStr() {
        return str;
    }

    public void setStr(String str) {
        this.str = str;
    }

    String str;

    public String edit(){
        try {
            projectOrderMapper.dynamicSQL("update TEST1 set name = '"+str+"' where id = '"+id+"'");
            System.out.println("success");
        }catch (Exception e){
            System.out.println("error");
            e.printStackTrace();
        }
        return null;
    }

    public String query() {
        try {
            OuProjectOrder projectOrders = (OuProjectOrder) projectOrderMapper.dynamicSQL("select * from TEST1 where id = '" + id + "'");
            System.out.println("return object = "+projectOrders);
        }catch (Exception e){
            System.out.println("error");
            e.printStackTrace();
        }
        return null;
    }
    public String queryList() {
        try {
            List<OuProjectOrder> test1 = (List<OuProjectOrder>) projectOrderMapper.dynamicSQLReturnList("select * from TEST1 where name = '" + str + "'");
            System.out.println("return objects = "+test1.size());
        }catch (Exception e){
            System.out.println("error");
            e.printStackTrace();
        }
        return null;
    }
    public String insert() {
        try {
            System.out.println("insert="+testService.insert());
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
    public String del() throws Exception{
        try {
            projectOrderMapper.deleteByPrimaryKey(id);
            System.out.println("success!");
        }catch (Exception e){
            System.out.println("error");
            e.printStackTrace();
        }
        return null;
    }
}
